#!/bin/bash

binDir=/usr/local/nsq/bin
logDir=/data/nsq/logs
broadcastAddr="127.0.0.1"
if [ ! -z $BROADCAST_ADDR ]
then
    broadcastAddr=$BROADCAST_ADDR
fi

if [ ! -d $logDir ]
then
    cd /data/nsq
    mkdir data logs
fi

$binDir/nsqlookupd --broadcast-address=$broadcastAddr >> $logDir/nsqlookupd.log 2>&1 &
$binDir/nsqd --lookupd-tcp-address=127.0.0.1:4160 --data-path=/data/nsq/data --broadcast-address=$broadcastAddr -max-msg-size=1073741824 -mem-queue-size=3 -max-body-size=1073741824 >> $logDir/nsqd.log 2>&1 &
$binDir/nsqadmin --lookupd-http-address=127.0.0.1:4161 >> $logDir/nsqadmin.log 2>&1

sleep infinity
